//
//  KeHuXVC.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/17.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "KeHuXVC.h"

#import "JieSuanThreeCell.h"
#import "DouSecondCell.h"
#import "DouDetailsCell.h"
#import "TodoHttpManager.h"
@interface KeHuXVC ()<UITableViewDataSource,UITableViewDelegate>

{
    NSArray *_keTitleArr;
    NSMutableDictionary *_dataDic;
    
    
    NSString *str;
    NSString *str1;
    NSString *str2;
    NSString *str3;
    NSString *str4;
    NSString *str5;
    NSString *str6;
    NSString *str7;
    NSString *str8;
    NSString *str9;
    NSString *str10;
    NSString *str11;
    NSString *str12;
    NSString *str13;
    NSString *str14;
    NSString *str15;
    NSString *str16;
    NSString *str17;
    NSString *str18;
    NSString *str19;
    NSString *str20;
    NSString *str21;
    NSString *str22;
    NSString *str23;
    NSString *strID;
    NSString *strNum;

}
@property(nonatomic,strong)UITableView *tabView;
@property (nonatomic,strong) NSMutableArray *daArr;
@end

@implementation KeHuXVC

-(void)viewWillAppear:(BOOL)animated
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didTDYongJinX:) name:TDYongJinX object:nil];
    
    [_manager UserGMYongJinXWithID:_keID withType:_Type];
}

-(void)didTDYongJinX:(NSNotification *)notifi
{
    if (notifi.object != nil)
    {
        int status = [[notifi.object objectForKey:@"status"] intValue];
        if (status == 1)
        {
            _dataDic = [notifi.object objectForKey:@"data"];
            
            str = [_dataDic objectForKey:@"sign_name"];
            strNum =  [_dataDic objectForKey:@"phone"];
            str1 = [_dataDic objectForKey:@"sign_time"];
            str2 = [_dataDic objectForKey:@"wylx"];
            str3 =  [_dataDic objectForKey:@"room_num"];
            str4 = [_dataDic objectForKey:@"area"];
            str5 =  [_dataDic objectForKey:@"hetong_price_all"];
            str6 = [_dataDic objectForKey:@"hetong_price"];
            str7 =  [_dataDic objectForKey:@"pay_way"];
            str8 = [_dataDic objectForKey:@"hk_status"];
            str9 =  [_dataDic objectForKey:@"hk_time"];
            str10 = [_dataDic objectForKey:@"yj_bl"];
            str11 = [_dataDic objectForKey:@"yj_yj"];
            str12 = [_dataDic objectForKey:@"js1_money"];
            str13 = [_dataDic objectForKey:@"js2_money"];
            str14 =  [_dataDic objectForKey:@"yi_js1"];
            
            str15 = [_dataDic objectForKey:@"yi_js2"];
            str16 =  [_dataDic objectForKey:@"wei_js1"];
            str17 = [_dataDic objectForKey:@"wei_js2"];
            str18 =  [_dataDic objectForKey:@"jq_status"];
            
            
            
            
            
            _daArr = [[NSMutableArray alloc] initWithObjects:str,strNum,str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,str12,str17,str18, nil];
            
            
           // NSLog(@"111-----%lu",(unsigned long)_daArr.count);
            
            
            [_tabView reloadData];
        }
        else
        {
            [_manager MakeMyselfAlert:@"获取失败" andIsNeedTitle:NO andShowTime:2];
        }
    }

}
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:TDYongJinX object:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"佣金详情";
    _dataDic = [[NSMutableDictionary alloc] init];
    _manager = [TodoHttpManager sharedManager];
    _tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, B_WIDTH, B_HEIGHT) style:UITableViewStylePlain];
    _tabView.delegate = self;
    _tabView.dataSource = self;
    _tabView.rowHeight = 44;
    [self.view addSubview:_tabView];
    

    _keTitleArr = @[@"签约姓名 :",@"联系电话 :",@"签约日期 :",@"物业类型 :",@"房源位置 :",@"合同面积 :",@"合同总价 :",@"合同单价 :",@"付款方式 :",@"回款状态 :",@"回款日期 :",@"佣金标准 :",@"应接佣金 :",@"结算1 :",@"结算2 :",@"结清状态 :",];
    
    
    
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    
    
    return _keTitleArr.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
//    static NSString *cellID = @"Cell";
//    JieSuanThreeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
//    if (cell == nil)
//    {
//        cell = [[JieSuanThreeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
//    }
//    return cell;
    
    static NSString *cellIndent = @"";
    if (indexPath.row == 1)
    {
        cellIndent = @"CellA";
        DouSecondCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (cell ==nil)
        {
            cell = [[DouSecondCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndent];
            
            strNum =  [_dataDic objectForKey:@"phone"];
            cell.secondLab.text = [NSString stringWithFormat:@"%@",strNum];
            [cell setUpUIPbone:[_dataDic objectForKey:@"phone"]];
            
        }
        
        cell.firstLab.text= @"联系电话:";
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//取消点击
        return cell;
        
    }
    else if (indexPath.row == 13)
    {
        cellIndent = @"CellC";
        JieSuanThreeCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (cell == nil)
        {
            cell = [[JieSuanThreeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndent];
           
            str12 = [_dataDic objectForKey:@"js1_money"];
            str13 = [_dataDic objectForKey:@"js2_money"];
            str14 =  [_dataDic objectForKey:@"yi_js1"];
            
            str15 = [_dataDic objectForKey:@"yi_js2"];
            str16 =  [_dataDic objectForKey:@"wei_js1"];
            str17 = [_dataDic objectForKey:@"wei_js2"];
            
             cell.jieLab1.text = [NSString stringWithFormat:@"结算1 : %@元",str12];
            cell.yiJie1.text = [NSString stringWithFormat:@"已结算 : %@元",str14];
            cell.weiJie1.text = [NSString stringWithFormat:@"未结算 : %@元",str16];
        }
        return cell;
    }
    else if (indexPath.row == 14)
    {
        cellIndent = @"CellD";
        JieSuanThreeCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (cell == nil)
        {
            cell = [[JieSuanThreeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndent];
            
            str12 = [_dataDic objectForKey:@"js1_money"];
            str13 = [_dataDic objectForKey:@"js2_money"];
            str14 =  [_dataDic objectForKey:@"yi_js1"];
            
            str15 = [_dataDic objectForKey:@"yi_js2"];
            str16 =  [_dataDic objectForKey:@"wei_js1"];
            str17 = [_dataDic objectForKey:@"wei_js2"];
            
            cell.jieLab1.text = [NSString stringWithFormat:@"结算2 : %@元",str13];
            cell.yiJie1.text = [NSString stringWithFormat:@"已结算 : %@元",str15];
            cell.weiJie1.text = [NSString stringWithFormat:@"未结算 : %@元",str17];
        }
        return cell;
    }
    else
    {
        cellIndent = @"CellB";
        DouDetailsCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (cell ==nil)
        {
            cell = [[DouDetailsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndent];
            
            
        }
        if ([cell isKindOfClass:[DouDetailsCell class]])
        {
            if (_daArr.count != 0)
            {
                
                NSString *str0 = (NSString *)_daArr[indexPath.row];
                cell.secondLab.text = [NSString stringWithFormat:@"%@",str0];
               // NSLog(@"jiciya-----%@",_daArr);
            }
            
        }
        
        cell.firstLab.text = _keTitleArr[indexPath.row];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//取消点击
        return cell;
        
    }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
